<div id="main">
    <table cellspacing="0" class="list">
        <tr>
            <th>编号</th>
            <th>章节</th>
            <th>课时</th>
            <th>学习时间</th>
            <th>持续时间</th>
            <th>测验成绩</th>
        </tr>
        <?php foreach ($records as $record): ?>
        <tr class="hover">
            <td><?php echo $record['id'] ?></td>
            <td><?php echo $record['chapter_name'] ?></td>
            <td><?php echo $record['lesson_name'] ?></td>
            <td><?php echo $record['created'] ?></td>
            <td><?php echo secondsToSting($record['duration']) ?></td>
            <td><?php echo $record['exam_score'] == -1 ? '未参加' : $record['exam_score'] ?></td>
        </tr>
        <?php endforeach ?>
    </table>
    <?php echo $pagination ?>
</div>

<?php

/**
 * 将秒数转换为可读的字符串表示
 * 
 * @param int $seconds 描述
 */
function secondsToSting($seconds)
    {
    	if ($seconds < 60) {
    		return "{$seconds}秒";
    	} else if ($seconds < 3600) {
    		$minutes = floor($seconds / 60);
    		$seconds = $seconds % 60;
    		return "{$minutes}分{$seconds}秒";
    	} else {
    		$hours   = floor($seconds / 3600);
    		$minutes = floor($seconds % 3600 / 60);
    		$seconds = $seconds % 60;
    		return "{$hours}小时{$minutes}分{$seconds}秒";
    	}
    }
?>